#include "TimeoutQueue.hh"

TimeoutQueue::TimeoutQueue()
{
	if (!State)
		return;
	
	State = false;
	
	ResultOf Result;
	Result = setTimeout_(100000); // 0.1 sec
	checkErrorFV(Result, "Fail setTimeout_.");
	
	State = true;
}

TimeoutQueue::TimeoutQueue(USNumber WaitingTime)
{
	if (!State)
		return;
	
	State = false;
	
	ResultOf Result;
	Result = setTimeout_(WaitingTime);
	checkErrorFV(Result, "Fail setTimeout_.");
	
	State = true;
}

ResultOf TimeoutQueue::setTimeout(USNumber WaitingTime)
{
	if (!State)
	{
		fprintf(stderr, "This instance(%x) is not available.\n", (Number)this);
		return RETURN_ERROR;
	}
	
	ResultOf Result;
	Result = setTimeout_(WaitingTime);
	checkErrorWR(Result, "Fail setTimeout_.");
	
	return RETURN_OK;
}

ResultOf TimeoutQueue::setTimeout_(USNumber WaitingTime)
{
	ResultOf Result;
	Result = SignalOfInputEvent->setTimeout(WaitingTime);
	checkErrorWR(Result, "Fail SignalOfInputEvent->setTimeout.");
	
	return RETURN_OK;
}

